<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>企业收费记录</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../../js/layui/css/layui.css" media="all">
</head>
<body>
<!--搜索框-->
<!--<div class="layui-form">-->
<!--    <div class="layui-form-item" style="margin-bottom: 30px;text-align: center;">-->
<!--        <div class="layui-inline">-->
<!--            &lt;!&ndash;<label class="layui-form-label">缴费人名字或编号</label>&ndash;&gt;-->
<!--            <div class="layui-input-inline">-->
<!--                <input type="text" name="gsName" placeholder="请输入缴费人名字或编号" autocomplete="off" class="layui-input" />-->
<!--            </div>-->
<!--        </div>-->
<!--        <div class="layui-inline">-->
<!--            <button class="layui-btn layuiadmin-btn-list" lay-submit lay-filter="search-qiye-submit">-->
<!--                <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>-->
<!--            </button>-->
<!--        </div>-->
<!--    </div>-->
<!--</div>-->
<blockquote class="layui-elem-quote quoteBox mod_default_box">
    <form class="layui-form">
        <div class="layui-form-inline">
            <label class="layui-form-label">缴费日期</label>
            <div class="layui-input-inline">
                <input type="text" id="start_time" name="start_time" autocomplete="off" placeholder="请输入开始时间" class="layui-input">
            </div> 至
            <div class="layui-input-inline">
                <input type="text" id="end_time" name="end_time" autocomplete="off" placeholder="请输入结束时间" class="layui-input">
            </div>

            <div class="layui-input-inline" style="padding-left: 50px;">
                <input type="text" name="gsName" style="width: 190px" placeholder="请输入公司名称" autocomplete="off" class="layui-input" />
            </div>
            <button class="layui-btn layuiadmin-btn-list" lay-submit lay-filter="search-qiye-submit">
                <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
            </button>
        </div>
    </form>
</blockquote>

<!--数据列表-->
<table class="layui-hide" id="test" lay-filter="qiye-table" style="margin: 0 auto;"></table>

<script type="text/html" id="qiye-toolbar">
    <a class="layui-btn layui-btn-xs" lay-event="edit"><i class="layui-icon layui-icon-edit"></i>编辑</a>
    <!--<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del"><i class="layui-icon layui-icon-delete"></i>删除</a>-->
</script>
<script src="../../js/layui/layui.js"></script>
<script src="../../js/layui/layui.all.js"></script>
<script src="../../js/token.js"></script>
<script src="../../js/config.js"></script>

<script>
    layui.use(['table'], function() {
        var $ = layui.$;
        var table = layui.table;
        var layer = layui.layer;
        var form = layui.form;
        table.render({
            elem: '#test'
            , id: 'shoufei'//重载需要
            , url: HOST+'qiyeShoufei/qiyeShoufeijilu'
            ,title: '收费记录表'
            ,cols: [[
                {field:'', title:'序号',width:80, fixed: 'left', unresize: true, type:'numbers'}
                // ,{field:'staffName',align : 'center', width:150,title:'缴费人'}
                // ,{field:'bh',align : 'center', width:150,title:'编号'}
                ,{field:'qyName',align : 'center', width:150,title:'缴费企业'}
                // ,{field:'phone',align : 'center', width:150,title:'联系方式'}
                // ,{field:'sfz',align : 'center', width:150,title:'证件号码'}
                ,{field:'money',align : 'center', width:140,title:'金额'}
                ,{field:'sfTime',align : 'center',width:180,title:'缴费时间',sort:true}
                ,{field:'jsTime',align : 'center',width:180,title:'到期时间',sort:true}
                ,{toolbar: "#qiye-toolbar",align : 'center',width:160,  title: "操作"}
            ]]
            ,page: true
            ,page: {
                curr: layui.data("qiyeshoufei_page").index
            },
            done: (res, curr, count) => {
                layui.data("qiyeshoufei_page", {
                    key: 'index',
                    value: curr
                });
            }
        });

        //搜索操作
        form.on('submit(search-qiye-submit)', function (data) {
            table.reload('shoufei', {
                where: {"qiye": data.field.gsName,"start_time":data.field.start_time,"end_time":data.field.end_time }
                , page: {
                    curr: 1
                }
            });
            return false;
        });

        //表操作  监听操作
        table.on('tool(qiye-table)', function (obj) {
            var data=obj.data;
            var event = obj.event;
            //删除
            if (event === 'del') {
                layer.confirm('确认删除该记录吗？', function (index) {
                    $.ajax({
                        url: HOST+"shoufei/deljilu?id=" + data.id
                        , type: "GET"
                        , dataType: "json"
                        , success: function (data) {
                            if (data.code == 0) {
                                layer.msg("删除成功");
                                table.reload("shoufei");
                            } else {
                                layer.msg("删除失败");
                            }
                        }
                        , error: function () {
                            console.log("ajax error");
                        }
                    });
                    layer.close(index);
                });
            } else if (event === 'edit') {
                layer.open({
                    type:2
                    ,title:"编辑企业收费记录"
                    ,skin:'layui-layer-molv'
                    ,area: ['90%', '90%']
                    ,content:(encodeURI("updqiyeShoufeijilu.html?id="+data.id+"&qyName="+data.qyName+"&qyID="+data.qyID+"&ksTime="+data.ksTime+"&jsTime="+data.jsTime+"&money="+data.money))  //js获取url参数
                });
            }
        });
    });
</script>

<script>
    layui.use('laydate', function(){
        var laydate = layui.laydate;
        var endDate= laydate.render({
            elem: '#end_time',//选择器结束时间
            type: 'datetime',
            min:"1970-1-1",//设置min默认最小值
            done: function(value,date){
                startDate.config.max={
                    year:date.year,
                    month:date.month-1,//关键
                    date: date.date,
                    hours: 0,
                    minutes: 0,
                    seconds : 0
                }
            }
        });
        //日期范围
        var startDate=laydate.render({
            elem: '#start_time',
            type: 'datetime',
            max:"2099-12-31",//设置一个默认最大值
            done: function(value, date){
                endDate.config.min ={
                    year:date.year,
                    month:date.month-1, //关键
                    date: date.date,
                    hours: 0,
                    minutes: 0,
                    seconds : 0
                };
            }
        });
    });
</script>

</body>
</html>